#ifndef __JSON_PATH_CONDITION_H__
#define __JSON_PATH_CONDITION_H__

#include <string>
#include <vector>

#include "Poco/JSON/Object.h"

class JsonPathFilterExprData
{
public:
    JsonPathFilterExprData() { m_eOperatorType = LOGIC_OPR_NO; }
    enum OperatorType
    {
        LOGIC_OPR_NO,   // None
        LOGIC_OPR_GT,   // Greate
        LOGIC_OPR_LT,   // Little
        LOGIC_OPR_EQ,   // Equale
        LOGIC_OPR_GE,   // Greate Equale
        LOGIC_OPR_LE,   // Little Equale
        LOGIC_OPR_NE    // Not Equale
    };
    std::string m_strKey; // key > 10
    OperatorType m_eOperatorType;
    std::string m_strValue;
    std::string m_strLeftLogic; // && ||
    template <typename T>
    bool DoLogic(T vl, T vr);
};

class JsonPathFilterExpr
{
public:
    JsonPathFilterExpr() { m_bValid = false; }
    JsonPathFilterExpr(const JsonPathFilterExpr& stExpr);
    JsonPathFilterExpr& operator=(const JsonPathFilterExpr& stExpr);
    ~JsonPathFilterExpr();
    JsonPathFilterExpr(std::string strLeftLogic, std::string strExpr);

public:
    bool ExprResult(Poco::JSON::Object::Ptr pObj, bool bLeftResult);
    bool IsValid(bool bLeftCondition = false);
    void PushSubExpr(JsonPathFilterExpr* pExpr);

private:
    bool Tokenization(std::string str);

public:
    std::string m_strUUID;
    bool m_bValid;
    JsonPathFilterExprData m_stData;

private:
    std::vector<JsonPathFilterExpr*> m_vectSubExpr;
};

#endif // !__JSON_PATH_CONDITION_H__
